package com.example.test_activity.utils;



import android.util.Log;

import java.util.Calendar;

/**
 * Created by 旭 on 2017/3/31/031.
 */

public class GetTime {
    Calendar time = Calendar.getInstance();
    private int year_now = time.get(Calendar.YEAR);
    private int month_now = time.get(Calendar.MONTH)+1;
    private int day_now = time.get(Calendar.DAY_OF_MONTH);
    private int year_start;
    private int month_start;
    private int day_start;
    public int week;

    private int days = 0;
    private int index = 1;

    public int getWeek()
    {
        week = time.get(Calendar.DAY_OF_WEEK)-1;
        if (week < 0)
            week = 0;

        return week;
    }

    public int getTime()
    {
        int[] arr= new int[] {0,31,28,31,30,31,30,31,31,30,31,30,31};
        year_start = year_now;
        if (month_now >= 9)
        {
            month_start = 9;
            day_start = 4;
        } else {
            month_start = 2;
            day_start = 27;
        }

        int k = day_start;
        for (int i=month_start;i<=month_now;++i)
        {
            for (int j=k;j<=arr[i];++j)
            {
                if (i == month_now && j > day_now)
                {
                    break;
                }
                ++days;
            }
            k = 1;
        }

        if (days%7 == 0)
        {
            index = days / 7;
        }else {
            index = (days / 7)+1;
        }

        return index;
    }
}
